import com.mobilerobots.Aria.*;

public class ArturitoExplorer
{

   //------------------------------------------------------------
   // ATRIBUTOS
   //------------------------------------------------------------

	private ArRobot Arturito;
	private ArSimpleConnector conn;
	//Sensores
	private ArSonarDevice sonar;
static {
    try {
        System.loadLibrary("AriaJava");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library libAriaJava failed to load. Make sure that its directory is in your library path; See javaExamples/README.txt and the chapter on Dynamic Linking Problems in the SWIG Java documentation (http://www.swig.org) for help.\n" + e);
      System.exit(1);
    }
  }


   //------------------------------------------------------------
   // METODOS
   //------------------------------------------------------------

	public ArturitoExplorer(String[] argv)
	{
		Aria.init();
		conn = new ArSimpleConnector(argv);
		Arturito = new ArRobot();
		 sonar = new ArSonarDevice();
		Arturito.addRangeDevice(sonar );
		if(!Aria.parseArgs())
        {
          Aria.logOptions();
          Aria.shutdown();
          System.exit(1);
        }

        if (!conn.connectRobot(robot))
        {
          System.err.println("Could not connect to robot, exiting.\n");
          System.exit(1);
        }
		
		Arturito.runAsync(true);
			   		while (true)
					{
							explorar();	
							esquivar();	
					}

			private void explorar(){

				Arturito.lock();
				Arturito.enableMotors();
				Arturito.move( 100);
				Arturito.unlock();
				ArUtil.sleep(200); 
			}
			private void esquivar(){

				ArUtil.sleep(200); 
			}
 	}
    public static void main(String[] args) {
  	 ArturitoExplorer sm=new ArturitoExplorer(args);
  	}



} 



